/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.gen2phen.labs.domain;

import java.util.HashMap;

/**
 *
 * @author pedrolopes
 *
 * GEN2PHEN Semantic Web Labs: Knowledge Netowork
 *
 */
public class Disease {

    private String name;
    private int omim;
    private String diseaseClass;
    public HashMap<String, Gene> genes = new HashMap<String, Gene>();
    public HashMap<String, Drug> drugs = new HashMap<String, Drug>();

    public Disease() {
    }

    public HashMap<String, Drug> getDrugs() {
        return drugs;
    }

    public void setDrugs(HashMap<String, Drug> drugs) {
        this.drugs = drugs;
    }

    public String getDiseaseClass() {
        return diseaseClass;
    }

    public void setDiseaseClass(String diseaseClass) {
        this.diseaseClass = diseaseClass;
    }

    public HashMap<String, Gene> getGenes() {
        return genes;
    }

    public void setGenes(HashMap<String, Gene> genes) {
        this.genes = genes;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getOmim() {
        return omim;
    }

    public void setOmim(int omim) {
        this.omim = omim;
    }

    public Disease(String name, int omim, String diseaseClass) {
        this.name = name;
        this.omim = omim;
        this.diseaseClass = diseaseClass;
    }

    public boolean addGene(Gene g) {
        boolean success = false;

        try {
            genes.put(g.getSymbol(), g);
            success = true;
        } catch (Exception e) {
            System.out.println("[Disease] error " + e.toString());
        }

        return success;
    }

    /**
     * Associates a given Drug to the Disease.
     *
     * @param d The Drug.
     * @return Success of the operation
     */
    public boolean addDrug(Drug d) {
        boolean success = false;

        try {
            // add Drug to drugs HashMap
            drugs.put(d.getName(), d);
            success = true;
        } catch (Exception e) {
            System.out.println("[Disease] error " + e.toString());
        }

        return success;
    }

    /**
     * Overriden toString method to include all disease information and associated drug information.
     * 
     * @return
     */
    @Override
    public String toString() {
        String response = "\n\t - " + this.name + "\n\t - " + this.omim + "\n\t - " + this.diseaseClass;

        for (Drug d : drugs.values()) {
            response += d.toString();
        }
        return response;
    }
}
